home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / perl5 / perl5.002 / makeaperl < prev    next >
Encoding:
Text File  |  1996-03-26  |  3.1 KB  |  104 lines

  1. #!/gnu/bin/perl
  2.     eval 'exec perl -S $0 "$@"'
  3.     if 0;
  4.  
  5. =head1 NAME
  6.  
  7. makeaperl - create a new perl binary from static extensions
  8.  
  9. =head1 SYNOPSIS
  10.  
  11. C<makeaperl -l library -m makefile -o target -t tempdir [object_files] [static_extensions] [search_directories]>
  12.  
  13. =head1 DESCRIPTION
  14.  
  15. This utility is designed to build new perl binaries from existing
  16. extensions on the fly. Called without any arguments it produces a new
  17. binary with the name C<perl> in the current directory. Intermediate
  18. files are produced in C</tmp>, if that is writeable, else in the
  19. current directory. The most important intermediate file is a Makefile,
  20. that is used internally to call C<make>. The new perl binary will consist
  21.  
  22. The C<-l> switch lets you specify the name of a perl library to be
  23. linked into the new binary. If you do not specify a library, makeaperl
  24. writes targets for any C<libperl*.a> it finds in the search path. The
  25. topmost target will be the one related to C<libperl.a>.
  26.  
  27. With the C<-m> switch you can provide a name for the Makefile that
  28. will be written (default C</tmp/Makefile.$$>). Likewise specifies the
  29. C<-o> switch a name for the perl binary (default C<perl>). The C<-t>
  30. switch lets you determine, in which directory the intermediate files
  31. should be stored.
  32.  
  33. All object files and static extensions following on the command line
  34. will be linked into the target file. If there are any directories
  35. specified on the command line, these directories are searched for
  36. C<*.a> files, and all of the found ones will be linked in, too. If
  37. there is no directory named, then the contents of $INC[0] are
  38. searched.
  39.  
  40. If the command fails, there is currently no other mechanism to adjust
  41. the behaviour of the program than to alter the generated Makefile and
  42. run C<make> by hand.
  43.  
  44. =head1 AUTHORS
  45. Tim Bunce <Tim.Bunce@ig.co.uk>, Andreas Koenig
  46. <koenig@franz.ww.TU-Berlin.DE>; 
  47.  
  48. =head2 STATUS
  49. First version, written 5 Feb 1995, is considered alpha.
  50.  
  51. =cut
  52.  
  53. use ExtUtils::MakeMaker;
  54. use Getopt::Long;
  55. use strict qw(subs refs);
  56.  
  57. $Version = 1.0;
  58. $Verbose = 0;
  59.  
  60. sub usage{
  61.     warn <<END;
  62. $0 version $Version
  63.  
  64. $0: [options] [object_files] [static_extensions ...] [directories to search through]
  65.  -l perllibrary     perl library to link from (the first libperl.a found)
  66.  -m makefilename    name of the makefile to be written (/tmp/Makefile.\$\$)
  67.  -o name            name for perl executable (perl)
  68.  -t directory       directory where intermediate files reside (/tmp)
  69. END
  70.     exit 1;
  71. }
  72.  
  73. if (-w "/tmp") {
  74.     $opt_t = "/tmp";
  75. } else {
  76.     $opt_t = ".";
  77. }
  78. $opt_l = '';
  79. $opt_m = "$opt_t/Makefile.$$";
  80. $opt_o = 'perl';
  81.  
  82. $Getopt::Long::ignorecase=0;
  83.  
  84. GetOptions('t=s', 'l=s', 'm=s', 'o=s') || die &usage;
  85.  
  86. @dirs = grep -d $_, @ARGV;
  87. @fils = grep -f $_, @ARGV;
  88.  
  89. @dirs = $INC[0] unless @dirs;
  90.  
  91. open MAKE, ">$opt_m";
  92. MM->init_main();
  93. MM->init_others();
  94. print MAKE MM->makeaperl('MAKE'    => $opt_m,
  95.              'TARGET'  => $opt_o,
  96.              'TMP'     => $opt_t,
  97.              'LIBPERL' => $opt_l,
  98.              'DIRS'    => [@dirs], 
  99.              'STAT'    => [@fils], 
  100.              'INCL'    => [@dirs]
  101. );
  102. close MAKE;
  103. (system "make -f $opt_m") == 0 or die "$0 failed: Please check file $opt_m and run make -f $opt_m\n";
  104.